package com.se7en.ufutil;

import android.graphics.drawable.Drawable;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;

public class GenericOverlayItem extends OverlayItem {

	Drawable zoomedIn;
	Drawable zoomedOut;
	MapView	 mapView;


	public GenericOverlayItem(GeoPoint point, String title, String snippet, Drawable zoomedOut, Drawable zoomedIn, MapView map) {
		super(point, title, snippet);
		
		this.zoomedIn = zoomedIn;		//Paul: large icon
		this.zoomedOut = zoomedOut;		//Paul: small icon
		this.mapView = map;				//Paul: used in order to get zoomlevel, trying to figure out a better way
		
	}


	@Override
	public Drawable getMarker(int stateBitset) {
		Drawable result;
		int zoom = mapView.getZoomLevel();
		if ( zoom > 16 ) { 				//Paul: if zoom is close, then display larger marker (zoom > 16 is when the map displays more detailed buildings)
			result = zoomedIn;
		} else {
			result = zoomedOut;
		}
		//Forget what this does, I think it's something necessary because the original method does it?
		setState(result, stateBitset);
		//Paul: this one is definitely necessary or else your icon won't show
		result.setBounds(-result.getIntrinsicWidth()/2, -result.getIntrinsicHeight(), result.getIntrinsicWidth() /2, 0); 
		


		return result;
	}
	



}
